﻿@model TemplateContext<AutoShape>

@{
	AutoShape contextObject = Model.Object;
	
	var origin = Model.Local.Get<Point>("origin");
	var positionStyle = string.Format("left: {0}px; top: {1}px; width: {2}px; height: {3}px;",
										(int)contextObject.X + origin.X,
										(int)contextObject.Y + origin.Y,
										(int)contextObject.Width,
										(int)contextObject.Height);
}

@functions
{
	string GetShapeStyle(AutoShape shape)
	{
		string background = FillHelper.GetFillStyle(shape.FillFormat.GetEffective(), Model);
		string borderStyle = string.Format("border: {0};", LineHelper.GetLineStyle(shape.LineFormat.GetEffective()));
				
		return string.Join(" ", background, borderStyle);
	}
}

@{
	<div class="shape" style="@positionStyle @GetShapeStyle(contextObject)">
		@{
			var subModel = Model.SubModel((TextFrame)contextObject.TextFrame);
			subModel.Local.Put("origin", origin);
			subModel.Local.Put("parent", contextObject);
			
			@Include("textframe", subModel)        
		}
	</div>
}